package com.zd.controller;

import com.zd.domain.Result;
import com.zd.service.SmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping ("/sms")
public class SmsController {

    @Autowired
    private SmsService smsService;
    @CrossOrigin
    @GetMapping
    public Result<Integer> sendMessage(@RequestParam("phone") String phone){
        Result<Integer> result = new Result<>();

        int resultNum = smsService.sendMessage(phone);

        if (resultNum == 1){
            result.setCode(2000);
            result.setMsg("发送手机验证码成功！");
            result.setData(resultNum);
        }else {
            result.setCode(4000);
            result.setMsg("发送手机验证码失败！");
        }

        return result;
    }


}
